
/**
 * @Title: UploadSgsController.java
 * @Package com.py.credit.controller
 * @Description: TODO
 * Copyright: Copyright (c) 2020
 * Company:金电联行(江苏)信息技术有限公司
 * @author Comsys-jdzc
 * @date 2020年10月20日 上午10:05:28
 * @version V1.0
 */

package com.py.credit.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.py.credit.common.logs.ExceptionLogger;
import com.py.credit.common.rest.RestServiceResult;
import com.py.credit.service.UploadSgsService;
import com.py.framework.core.annotation.IgnoreAuthority;

/**
 * @ClassName: UploadSgsController
 * @Description: TODO(这里用一句话描述这个类的作用)
 * @author jdzc
 * @date 2020年10月20日 上午10:05:28
 *
 */
@RestController
@RequestMapping("/uploadsgs")
public class UploadSgsController {

	// 业务系统方法
	@Value("${sysMethod}")
	private String sys_method;
	
	// 密钥
	@Value("${accessKey}")
	private String access_key;
	
	// 密钥
	@Value("${bjsecretKey}")
	private String secret_key;
	
	@Autowired
    private UploadSgsService upLoadService;

    /**
     * 上传双公示数据
     * 0 法人许可 1 自然人许可 2法人处罚 3自然人处罚
     */
    @IgnoreAuthority
    @RequestMapping(value = "/uploadSgsTask.do")
    public RestServiceResult<Object>  uploadXzxk(int type)  {
    	RestServiceResult<Object> result = new RestServiceResult<Object>();
        
        try {
            Object data = upLoadService.run(type,sys_method,access_key,secret_key);
        	result.setData(data);
			return result;
        } catch (Exception e) {
        	ExceptionLogger.error("UploadSgsController#uploadSgsTask", "数据推送异常！ERROR：" + e.getMessage(), e);
        	result.setCode(RestServiceResult.CODE_UNKNOW);
			result.setMsg("双公示推送定时任务异常！");
			return result;
        }
        
    }
    
    /**
     * 修改推送状态
     */
    @IgnoreAuthority
    @RequestMapping(value = "/updatePushStatus.json")
    public RestServiceResult<Object>  updatePushStatus(Integer tableId,Integer record_id)  {
    	RestServiceResult<Object> result = new RestServiceResult<Object>();
        
        try {
            upLoadService.updatePushStatus(tableId,record_id);
        	
			return result;
        } catch (Exception e) {
        	ExceptionLogger.error("UploadSgsController#updatePushStatus", "修改推送状态异常！ERROR：" + e.getMessage(), e);
        	result.setCode(RestServiceResult.CODE_UNKNOW);
			result.setMsg("修改推送状态异常！");
			return result;
        }
        
    }
    
  
}
